from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
from options import options

url = r'http://172.16.22.105:8080/bsams/front/login.do'
driver = webdriver.Chrome(options=options)
driver.get(url)
driver.maximize_window()
sleep(2)

# 登录
driver.find_element(By.ID, 'taskId').clear()
driver.find_element(By.ID, 'taskId').send_keys('1')
driver.find_element(By.ID, 'loginName').clear()
driver.find_element(By.ID, 'loginName').send_keys('test16')
driver.find_element(By.ID, 'password').clear()
driver.find_element(By.ID, 'password').send_keys('123456')
driver.find_element(By.ID, 'vericode').clear()
driver.find_element(By.ID, 'vericode').send_keys('shtd')
driver.find_element(By.XPATH, '//*[@id="fmedit"]/div[2]/div[6]/input').click()
sleep(3)

# # 退出
# driver.find_element(By.LINK_TEXT, '退出').click()
# sleep(3)

# # 修改手机号
driver.find_element(By.ID, 'phone').clear()
driver.find_element(By.ID, 'phone').send_keys('17534741512')
driver.find_element(By.LINK_TEXT, '保存').click()
driver.switch_to.alert.accept()
sleep(2)

# # 修改密码
driver.find_element(By.LINK_TEXT, '修改密码').click()
driver.find_element(By.ID, 'oldPassword').clear()
driver.find_element(By.ID, 'oldPassword').send_keys('123456')
driver.find_element(By.ID, 'newPassword1').clear()
driver.find_element(By.ID, 'newPassword1').send_keys('123456')
driver.find_element(By.ID, 'newPassword2').clear()
driver.find_element(By.ID, 'newPassword2').send_keys('123456')
driver.find_element(By.XPATH, '//*[@id="cboxLoadedContent"]/div/div/div[2]/div[4]/div[1]').click()
sleep(2)
driver.switch_to.alert.accept()

# 点击资产管理
driver.find_element(By.LINK_TEXT, '资产管理').click()
# 新增资产
driver.find_element(By.XPATH, '/html/body/div[2]/div/div[2]/div[2]/div[2]/div/input').click()   # 点击新增按钮
driver.find_element(By.ID, 'title').clear()
driver.find_element(By.ID, 'title').send_keys('遥遥领先')
driver.find_element(By.ID, 'providerId').click()                                # 定位存放地点
driver.find_element(By.XPATH, '//*[@id="providerId"]/option[4]').click()        # 选择深圳华克科技公司
driver.find_element(By.ID, 'storageId').click()
driver.find_element(By.XPATH, '//*[@id="storageId"]/option[5]').click()         # 定位总经理办公室
driver.find_element(By.XPATH, '//*[@id="fm_new"]/div/div[1]/div/div[1]').click()
sleep(3)
driver.switch_to.alert.accept()

# 修改资产
# driver.find_element(By.LINK_TEXT, '休改').click()
# driver.find_element(By.ID, 'title').clear()
# driver.find_element(By.ID, 'title').send_keys('遥遥领先')
# driver.find_element(By.ID, 'storageId').click()
# driver.find_element(By.XPATH, '//*[@id="storageId"]/option[5]').click()         # 定位存放地点
# driver.find_element(By.ID, 'providerId').click()
# driver.find_element(By.XPATH, '//*[@id="providerId"]/option[4]').click()
# driver.find_element(By.XPATH, '//*[@id="fm_new"]/div/div[1]').click()
# sleep(3)
# driver.switch_to.alert.accept()

# 资产借用
# driver.find_element(By.LINK_TEXT, '//*[@id="fm_new"]/div/div[1]').click()
# driver.find_element(By.ID, 'departId').click()
# driver.find_element(By.XPATH, '//*[@id="departId"]/option[2]').click()
# driver.find_element(By.ID, 'remark').clear()
# driver.find_element(By.ID, 'remark').send_keys('遥遥领先遥遥领先遥遥领先')
# driver.find_element(By.XPATH, '//*[@id="fm_new"]/div/div[1]').click()
# driver.switch_to.alert.accept()

# # 资产归还
# driver.find_element(By.LINK_TEXT, '归还').click()
# driver.find_element(By.XPATH, '//*[@id="cboxLoadedContent"]/div/div/div[2]/div[2]/div[1]').click()
# sleep(2)

# 查询
# driver.find_element(By.ID, 'status').click()
# driver.find_element(By.XPATH, '//*[@id="status"]/option[2]').click()
# driver.find_element(By.ID, 'title').clear()
# driver.find_element(By.ID, 'title').send_keys('遥遥领先')
# driver.find_element(By.XPATH, '//*[@id="fmsearch"]/div[3]/button').click()
# sleep(3)


# 存放地点管理
# driver.find_element(By.LINK_TEXT, '存放地点').click()
#
# driver.find_element(By.ID, 'status').click()
# driver.find_element(By.XPATH, '//*[@id="status"]/option[2]').click()
# driver.find_element(By.ID, 'title').clear()
# driver.find_element(By.ID, 'title').send_keys('遥遥领先')
# driver.find_element(By.XPATH, '//*[@id="fmsearch"]/div[3]/input').click()
# sleep(3)

# # 供应商管理
# driver.find_element(By.LINK_TEXT, '供应商').click()
# driver.find_element(By.NAME, 'status').click()
# driver.find_element(By.XPATH, '//*[@id="fmsearch"]/div[1]/select/option[2]').click()
# driver.find_element(By.ID, 'title').clear()
# driver.find_element(By.ID, 'title').send_keys('遥遥领先')
# sleep(2)
# driver.find_element(By.XPATH, '//*[@id="fmsearch"]/div[3]/input').click()
# sleep(3)

